package behavioral.iterator.custom;


import behavioral.iterator.MenuItem;

public class DinerMenuIterator implements Iterator<MenuItem> {

    MenuItem[] ls;
    int index = -1;

    public DinerMenuIterator(MenuItem[] ls) {
        this.ls = ls;
    }

    @Override
    public boolean hasNext() {
        int i = index + 1;
        if (this.ls.length < i || this.ls[i] == null) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public MenuItem next() {
        index++;
        return this.ls[index];
    }
}
